package com.chanzany.prototype.deepClone;

public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepPrototype p = new DeepPrototype();
        p.name = "宋宋";
        p.deepCloneableTarget = new DeepCloneableTarget("铅笔","笔");
        //方式1
        DeepPrototype p2 = (DeepPrototype) p.clone();
        System.out.println(p.name+" "+p.deepCloneableTarget+" "+p.deepCloneableTarget.hashCode());
        System.out.println(p2.name+" "+p2.deepCloneableTarget+" "+p2.deepCloneableTarget.hashCode());
        //方式2
        DeepPrototype p3 = (DeepPrototype) p.deepClone();
        System.out.println(p.name+" "+p.deepCloneableTarget+" "+p.deepCloneableTarget.hashCode());
        System.out.println(p3.name+" "+p3.deepCloneableTarget+" "+p3.deepCloneableTarget.hashCode());

    }
}
